/*
 * Created on Feb 7, 2007
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.pricejd.rcx;

import java.io.DataOutputStream;
import java.io.IOException;

/**
 * @author Jon Price
 * @version 0.1.43
 * 
 * Move class represents commands and stuff.
 */
public class Move {
	private LightNavigator nav;
	private DataOutputStream out;
	int x;
	
	public Move(LightNavigator nav, DataOutputStream out) {
		this.nav = nav;
		this.out = out;
		x=0;
	}
	
	public void gotoPoint(int x, int y) {
		nav.gotoPoint(x, y);
		try {
			out.writeInt((int)nav.getX());
			out.writeInt((int)nav.getY());
			out.writeInt((int)nav.getAngle());
			out.flush();
		} catch (IOException e) {
		}
	}
	
	public void reset() {
		nav.reset();
		try {
			out.writeInt((int)nav.getX());
			out.writeInt((int)nav.getY());
			out.writeInt((int)nav.getAngle());
			out.flush();
		} catch (IOException e) {
		}
	}
	
	public void travel(int x) {
		nav.travel(x);
		try {
			out.writeInt((int)nav.getX());
			out.writeInt((int)nav.getY());
			out.writeInt((int)nav.getAngle());
			out.flush();
		} catch (IOException e) {
		}
	}
	
	public void rotate(int x) {
		nav.rotate(x);
		try {
			out.writeInt((int)nav.getX());
			out.writeInt((int)nav.getY());
			out.writeInt((int)nav.getAngle());
			out.flush();
		} catch (IOException e) {
		}
	}
}
